package com.hustcad.plm.pdm.user.service.impl;

import cn.hutool.core.lang.UUID;
import com.hustcad.plm.pdm.user.mapper.OptionMapper;
import com.hustcad.plm.pdm.user.service.OptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;


@Service
public class OptionServiceImpl implements OptionService {
    @Autowired
    OptionMapper optionMapper;

    public OptionServiceImpl(OptionMapper optionMapper) {
        this.optionMapper = optionMapper;
    }

    @Override
    public Integer add(Map<String, Object> map) {
        return optionMapper.add(map);
    }

    @Override
    public List<Map<String,Object>> list(Map<String, Object> map) {
        return optionMapper.list(map);
    }

    @Override
    public Integer edit(Map<String, Object> map) {
        return optionMapper.edit(map);
    }

    @Override
    public Integer delete(Map<String, Object> map) {
        return optionMapper.delete(map);
    }

    @Override
    public Integer addLink(Map<String, Object> map) {
        return optionMapper.addLink(map);
    }

    @Override
    public Integer editLink(Map<String, Object> map) {
        return optionMapper.editLink(map);
    }

    @Transactional
    @Override
    public void addOption(Map<String, Object> map) {
        String uuid= UUID.fastUUID().toString();
        map.put("id", uuid);
        optionMapper.add(map);
        map.put("id", UUID.fastUUID().toString());
        map.put("setting_id", map.get("setting"));
        map.put("k3cloud_id", uuid);
        optionMapper.addLink(map);
    }

    @Transactional
    @Override
    public void editOption(Map<String, Object> map) {
        optionMapper.editLink(map);
        optionMapper.edit(map);
    }

    @Override
    public Integer addEnum(Map<String, Object> map) {
        return optionMapper.addEnum(map);
    }

    @Override
    public Integer addEnumSelect(List<Map<String, Object>> list) {
        return optionMapper.addEnumSelect(list);
    }

    @Transactional
    @Override
    public void addEnumType(Map<String, Object> map,List<Map<String, Object>> list) {
        optionMapper.addEnum(map);
        optionMapper.addEnumSelect(list);

    }

    @Transactional
    @Override
    public void updateEnumType(Map<String, Object> map, List<Map<String, Object>> list) {
        optionMapper.updateEnum(map);
        optionMapper.deleteEnumSelect(map);
        optionMapper.addEnumSelect(list);
    }

    @Transactional
    @Override
    public void deleteEnumType(Map<String, Object> map, List<Map<String, Object>> list) {
        optionMapper.deleteEnumt(map);
        optionMapper.deleteEnumSelect(map);
    }

    @Override
    public Integer updateEnum(Map<String, Object> map) {
        return optionMapper.updateEnum(map);
    }

    @Override
    public Integer deleteEnumSelect(Map<String, Object> map) {
        return optionMapper.deleteEnumSelect(map);
    }

    @Override
    public Integer deleteEnumt(Map<String, Object> map) {
        return optionMapper.deleteEnumt(map);
    }

    @Override
    public List<Map<String, Object>> getEnum(Map<String, Object> map) {
        return optionMapper.getEnum(map);
    }

    @Override
    public List<Map<String, Object>> getEnumSelect(Map<String, Object> map) {
        return optionMapper.getEnumSelect(map);
    }

    @Override
    public Integer addOutSettingEnum(Map<String, Object> map) {
        return optionMapper.addOutSettingEnum(map);
    }

    @Override
    public List<Map<String, Object>> getOutEnumSelect(Map<String, Object> map) {
        return optionMapper.getOutEnumSelect(map);
    }

    @Override
    public Integer editOutPlmPartById(Map<String, Object> map) {
        return optionMapper.editOutPlmPartById(map);
    }

    @Override
    public Integer addInSettingEnum(Map<String, Object> map) {
        return optionMapper.addInSettingEnum(map);
    }

    @Override
    public List<Map<String, Object>> getInEnumSelect(Map<String, Object> map) {
        return optionMapper.getInEnumSelect(map);
    }


}
